package com.sihan.swvp.service.jc;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sihan.swvp.dao.jc.JcDsdwDao;
import com.sihan.swvp.entity.jc.JcDsdw;
@Service
public class JcDsdwService{

	@Autowired
	private JcDsdwDao dsdwDao;
	
	public Page<Map<String, Object>> getJcDsdw(Map<String, Object> params,Integer page,Integer limit) {
		if(page !=null && limit !=null){
			PageHelper.startPage(page, limit);
		}
		return dsdwDao.getJcDsdw(params);
	}
	
	public List<Map<String, Object>> getAllJcDsdw() {
		return dsdwDao.getAllJcDsdw();
	}

	public void addJcDsdw(JcDsdw bean) {
		dsdwDao.addJcDsdw(bean);
	}

	public void updateJcDsdw(JcDsdw bean) {
		dsdwDao.updateJcDsdw(bean);
	}

	public int deleteJcDsdw(Integer id) {
		return dsdwDao.deleteJcDsdw(id);
	}
	
	/**
	 * 验证编码和名称
	 * @param code
	 * @param dsdwName
	 * @return false(不存在)、ture(存在)
	 */
	public boolean getJcDsdwValidate(String code,String dsdwName,Integer id) {
		boolean isOk=false;
			Integer nubmer=dsdwDao.getJcDsdwValidate(code,dsdwName,id);
			if(nubmer!=0){
				isOk=true;
			}
		return isOk;
	}
}
